package com.stadyhelper.config;

import com.stadyhelper.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {//实例化接口
    @Autowired
    private LoginInterceptor loginInterceptor;//注入拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {//实现接口中的InterceptorRegistry方法注册拦截器
        registry.addInterceptor(loginInterceptor).excludePathPatterns("/login","/register");//注册和exclude
    }
}
